<?php
class Mhelp extends CI_Model {
	function __construct() {
		parent::__construct ();
	}
	
	function getQuestionList($page, $num) {
		$this->db->order_by ( "updateTime", "desc" );
		$this->db->limit ( $num, $page );
		$query = $this->db->get ( 'help' );
		return $query->result_array ();
	}
	
	function getQuestionbyId ($id){
		$this->db->where ( 'id', $id );
		$query = $this->db->get ( 'help' );
		return $query->row_array ();
	}
	
	function getQuestionNum() {
		return $this->db->count_all ( 'help' );
	}
	
	function addQuestion($data) {
		$this->db->insert ( 'help', $data );
		return $this->db->insert_id ();
	}
	
	function updateQuestion($data,$id){
		$this->db->where ( 'id', $id );
		$this->db->update ( 'help', $data );
		if ($this->db->affected_rows () > 0)
			return TRUE;
		else
			return FALSE;
	}
	
	function delQuestionbyId ($id){
		$this->db->where ( 'id', $id );
		$this->db->delete ( 'help' );
		if ($this->db->affected_rows () > 0)
			return TRUE;
		else
			return FALSE;
	}
}